package com.lcgroup.springdemo.demos.config;

import com.lcgroup.springdemo.demos.filter.MySecurityFilter0;
import com.lcgroup.springdemo.demos.filter.MySecurityFilter1;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.security.web.access.intercept.AuthorizationFilter;

import javax.annotation.Resource;


@Configuration
public class SecurityConfig {

    @Resource
    private MySecurityFilter0 mySecurityFilter0;
//
    @Resource
    private MySecurityFilter1 mySecurityFilter1;

    @Bean
    SecurityFilterChain securityFilterChain0(HttpSecurity http) throws Exception {
            http.antMatcher("/app/securityFilterChain0/**").addFilterBefore(mySecurityFilter0, AuthorizationFilter.class);
        return http.build();
    }


    @Bean
    SecurityFilterChain securityFilterChain1(HttpSecurity http) throws Exception {
        http.antMatcher("/securityFilterChain1/**").addFilterAfter(mySecurityFilter1, AuthorizationFilter.class);
        return http.build();
    }
}
